home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / SRCHPATH.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  510 b   |  20 lines

  1. /* searchpath function from page 383 of turbo c bible */
  2. #include<stdio.h>
  3. #include<dir.h>
  4. main(int argc, char **argv)
  5. {
  6.     char *path_buffer;
  7.     printf("this program searches for a file in all \n\
  8.     the directories specified in the path\n\
  9.     environment variable\n");
  10.     if(argc < 2)
  11.     {
  12.         printf("Usage: %s <filename>\n", argv[0]);
  13.         exit(0);
  14.     }
  15.     path_buffer = searchpath(argv[1]);
  16.     if(path_buffer == NULL)
  17.         printf("file: %s not found\n",argv[1]);
  18.     else
  19.         printf("found as: %s\n", path_buffer);
  20. }